module DSFMLGame;

import game.AbstractGame;

import dsfml.window.all;
import dsfml.system.all;
import dsfml.graphics.all;

public class DSFMLGame : AbstractGame
{
	private RenderWindow window;
	
	public this()
	{
		window = new RenderWindow(VideoMode(800, 600, 32), "DSFMLGame");
		window.setBackgroundColor(Color(0, 0, 0, 255));
		
		running = true;
	}
	
	public void update(float delta)
	{
		if (!window.isOpened())
		{
			running = false;
			return;
		}
		
		handleEvents();
	}
	
	public void draw(float delta)
	{
		window.display();
	}
	
	private void handleEvents() 
	{
		Event evt;
		while (window.getEvent(evt))
        {
            // Window closed or escape key pressed : exit
            if ((evt.Type == Event.EventType.CLOSED) ||
               ((evt.Type == Event.EventType.KEYPRESSED) && 
				   (evt.Key.Code == KeyCode.ESCAPE)))
            {
                running = false;
                break;
            }
        }
	}
}